$(function () {
    /**
     * 用户名检查
     */
    $("#username").blur(function () {
        checkUsername();
    });

    //打开头像列表
    $("#pic-btn").click(function () {
        login();
    });
});

/**
 * 用户名检查
 */
function checkUsername() {
    let userName = $("#userName").val();
    if (userName === "") {
        $("#log_nameError").text("用户名不能为空！");
        $("#userName").focus();
    }
}

function login() {
    checkUsername();
    let userName = $("#userName").val();
    let password = $("#password").val();
    $.ajax({
		type: "POST",
		url: path + "login",
        data: {"userName": userName, "password": password},// 你的formid
        error: function (request) {
            alert("Connection error");
        },
        success: function (data) {
            if (data.code === 200) {
				parent.location.href = '/sites/myMusic.html';
            } else {
                alert(result.msg);
            }
        }
    });
}